package com.leyou.item.service.mapper;

import com.leyou.common.bean.IBaseMapper;
import com.leyou.item.inter.pojo.Brand;
import com.leyou.item.inter.pojo.Category;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;

import java.util.List;

public interface CategoryMapper extends IBaseMapper<Category>, SelectByIdListMapper<Category, Long> {

    /** 根据品牌id查询商品分类 */
    @Select("SELECT * FROM tb_category WHERE id IN (SELECT category_id FROM tb_category_brand WHERE brand_id = #{bid})")
    List<Category> queryByBrandId(@Param("bid") Long bid);

    @Select("select * from tb_category order by id desc LIMIT 1")
    Category getNewestId();
}